package com.oauth.global.client.ui.feeds;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.DeckPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.Widget;
import com.oauth.components.client.rpc.OAuthAsnyCallBack;
import com.oauth.components.client.ui.HasInit;
import com.oauth.global.client.rpc.GlobalRemoteServiceAsync;
import com.rapwaves.feeds.FeedEngine;
import com.rapwaves.feeds.Feeds;

public class FeedTab extends Composite implements HasInit{

	private static FeedTabUiBinder uiBinder = GWT.create(FeedTabUiBinder.class);

	interface FeedTabUiBinder extends UiBinder<Widget, FeedTab> {
	}

	@UiField
	SimplePanel simplePanel;
	
	@UiField
	DeckPanel deckPanel;
	
	private long appId;
	public FeedTab(long l) {
		initWidget(uiBinder.createAndBindUi(this));
		this.appId = l;
	}

	public void init(){
		simplePanel.clear();
		deckPanel.showWidget(0);
		GlobalRemoteServiceAsync.INSTANCE.getFeeds(appId, new OAuthAsnyCallBack<Feeds>() {

			@Override
			public void onSuccess(Feeds feeds) {
				deckPanel.showWidget(1);
				simplePanel.add(FeedEngine.getWidget(feeds));
			}
		});
		
	}
	

}
